<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资管收益详情</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 70px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}

        .sq-button.sq-button-round.disabled{
            color: rgba(0,0,0,.30);
            background: #eaeaea;
            border: 1px solid #d8d8d8;
            cursor: not-allowed;
        }
    </style>
</head>

<body class="iframeBody">
	<div class="Wrapper">
	    <div class="searchArea">
	        <form id="searchBar">
	            <div class="fieldset1 clearFix">
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_33">
							<div class="label">融资租赁合同号</div>
							<div class="field">
								<span name="lsCntNo" id="lsCntNo"></span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">资方机构名称</div>
							<div class="field">
								<span name="fundRasInsNm" id="fundRasInsNm"></span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label"></div>
							<div class="field"><span></span></div>
						</div>
					</div>
				</div>
        	</form>
    	</div>

	    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_head">
            <table class="table_full">
                <tr>
                    <td><b>应收/应付合计(元): </b><span id="sumEarAmt"/></td>
                    <td><b>已收/已付合计(元): </b><span id="sumPaidUpAmt"></td>
                </tr>
            </table>
        </div>
        <div class="sqPanel_body">
    		<div id="ligergrid1" class="sq-grid"></div>
        </div>
    </div>
	</div>

<script type="text/javascript">

$(function() {
	loadPrjBscInfoPage();
});

function loadPrjBscInfoPage() {
    var wait_dialog;
    $.ajax({
        type: 'get',
        dataType: 'json',
        url: '<%=path%>/institution/earnings/loadPrjBscInfo.do?lsCntNo=${lsCntNo}',
        beforeSend: function () {
            wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
        },
        success: function (prjBscInfo) {
            wait_dialog.close();
            $("#lsCntNo").text(prjBscInfo.lsCntNo);
            $("#fundRasInsNm").text(prjBscInfo.fundRasInsNm);
            getOvdAmtSummary();
            loadListPage();
            if (prjBscInfo.insCode != 'zbbankx'){
				$("#ligergrid1").ligerGrid().toggleCol('vouchAmt', false);
				$("#ligergrid1").ligerGrid().toggleCol('svcAmt', false);
				$("#ligergrid1").ligerGrid().toggleCol('paidVouchAmt', false);
				$("#ligergrid1").ligerGrid().toggleCol('paidSvcAmt', false);
			}
        }
    });
}

function loadListPage() {
	$("#ligergrid1").ligerGrid({
		url: '<%=path%>/institution/earnings/initDetail.do?lsCntNo=${lsCntNo}',
		method : 'get',
	    columns: [
	        { display:'应还款时间', name:'payDt', minWidth:140, enabledSort:true,render: renderDate}, 
	        { display:'期次', name:'payPd', align:'right', minWidth:100, enabledSort:true}, 
	        { display:'资方支付表租金合计', name:'insFeeAmt', align:'right', minWidth:100, enabledSort:true,
                render:function(rowdata,index,value){ return '&yen;'+FormatMoney(rowdata.insFeeAmt/100); }
	        },
	        { display:'我司支付表租金合计', name:'sqFeeAmt', align:'right', minWidth:100, enabledSort:true,
                render:function(rowdata,index,value){ return '&yen;'+FormatMoney(rowdata.sqFeeAmt/100); }
	        },
	        { display:'应收/应付', name:'earAmt', align:'right', minWidth:100, enabledSort:true,
                render:function(rowdata,index,value){
                    var capFlow = '(应收)' ;
                    if(rowdata.capFlow == '2'){
                        capFlow = '(应付)'
                    }
                   if (rowdata.insCode == 'zbbankx'){
					   var earAmt = rowdata.earAmt + rowdata.vouchAmt ;
					   return '&yen;'+FormatMoney(earAmt/100)+capFlow;
					}
                	return '&yen;'+FormatMoney(rowdata.earAmt/100)+capFlow;
	        	}
	        },
			{ display:'应收担保费', name:'vouchAmt', align:'right', minWidth:100, enabledSort:true,
				render:function(rowdata,index,value){
					return '&yen;'+FormatMoney(rowdata.vouchAmt/100);
				}
			},
			{ display:'应收服务费', name:'svcAmt', align:'right', minWidth:100, enabledSort:true,
				render:function(rowdata,index,value){
					return '&yen;'+FormatMoney(rowdata.earAmt/100);
				}
			},
	        { display:'已收/已付', name:'paidUpAmt', align:'right', minWidth:100, enabledSort:true,
                render:function(rowdata,index,value){
	        		var paidUpAmt = rowdata.paidUpAmt + rowdata.paidVouchAmt ;
                	return '&yen;'+FormatMoney(paidUpAmt/100); }
	        },
			{ display:'已收担保费', name:'paidVouchAmt', align:'right', minWidth:100, enabledSort:true,
				render:function(rowdata,index,value){
					return '&yen;'+FormatMoney(rowdata.paidVouchAmt/100);
				}
			},
			{ display:'已收服务费', name:'paidSvcAmt', align:'right', minWidth:100, enabledSort:true,
				render:function(rowdata,index,value){
					return '&yen;'+FormatMoney(rowdata.paidUpAmt/100);
				}
			},
	        { display:'已收/已付时间', name:'lastPayDt', minWidth:140, enabledSort:true,render: renderDate},
	        { display:'租金逾期情况', name:'',  minWidth:30, enabledSort:true,
	        	render: function (rowdata, rowindex, value, column) { 
					var h = '';
					if(rowdata.isOverdue == 1){//合同到期提醒
						h = '<i class="ico_flasher"></i>';
					}else if(rowdata.validSt == "未续签"){
						h = '<i class="ico_flasher_blue"></i>';
					}
					return h;
				}	
	        }, 

	    ],
	    usePager: false,
        root: 'data',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: '100%',
        heightDiff: -2,
        enabledEdit: false,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: false,
        enabledSort: false
	});
	grid = liger.get("ligergrid1");
	grid.setHeight(500);
	grid.reload();
}
//格式化时间
function renderDate(rowdata, index, value) {
    var dateStr = "";
    if (null != value) {
        var date = new Date(value);
        dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
    }
    return dateStr;
}


//查询汇总
function getOvdAmtSummary() {
  $.ajax({
      type: 'get',
      dataType: 'json',
      url: '<%=path%>/institution/earnings/sumDtl.do?lsCntNo=${lsCntNo}',
      success: function (msg) {
          $("#sumEarAmt").text(FormatMoney(msg.SUMEARAMT / 100));
          $("#sumPaidUpAmt").text(FormatMoney(msg.SUMPAIDUPAMT / 100));
      }
  });
}
</script>

</body>
</html>
